package test.com.sms.selenium.singlepoint.util;

import org.openqa.selenium.By;

import test.com.sms.selenium.framework.SeleniumPageUtil;
import test.com.sms.selenium.util.SeleniumUtil;

public class SpIncidentEditFeaturesTabPageUtil extends
		SeleniumPageUtil {

	public final static By IEF_SPAN_HEAD = By.id("IncFeatures_RptFeatureCodes_Header_lblHeader");
	public final static By IEF_IMG_PERFER = By.id("IncFeatures_RptFeatureCodes_Header_imgPreferences");
	public final static By IEF_IMG_EXPORT = By.id("IncFeatures_RptFeatureCodes_Header_imgExcelExport");
	public static void enterFeatureTab(String incidentId){
		// login into homepage
		SpSearchPageUtil.enter();
		// current window handle
		// make sure search button and incident id input text show
		SeleniumUtil.assertTrue(SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(SpIncidentEditPageUtil.IE_BUTTON_SEARCH)));
		SeleniumUtil.assertTrue(SeleniumUtil.isDisplayed(SeleniumUtil.getCachedElement(SpIncidentEditPageUtil.IE_MAIN_INPUT_INCIDENT_ID)));
		// click the incident id link to enter the edit page
		SpIncidentEditPageUtil.enterIncidentID(incidentId);
		//click Assets link to enter incident/Asset edit page
		SeleniumUtil.click(SeleniumUtil.getCachedElement(SpIncidentEditPageUtil.IE_LINK_TAB_FEATURES));
		waitForPageToLoad();
	}
	public static void waitForPageToLoad(){
		SeleniumUtil.selectDefaultContent();
		SeleniumUtil.waitOnElements(new By[]{
				IEF_SPAN_HEAD,IEF_IMG_EXPORT
		});
	}
}
